import { List } from "antd-mobile"
import { useHistory } from "react-router-dom"
import React, { useEffect, useState } from "react"
import {
    UnorderedListOutline,
    PayCircleOutline,
    SetOutline,
} from 'antd-mobile-icons'
import './index.css'
import { httpJson } from "../../../services/http"
const Manage: React.FC = () => {
    const [merchantInfo, setMerchantInfo] = useState<any>({})
    const [loading, setLoading] = useState<boolean>(false)
    const history = useHistory()
    useEffect(() => {
        setLoading(true)
        httpJson('GET', '/api/merchant/getMerchantIncomeInfo')
            .then((res: any) => {
                console.log(res)
                setMerchantInfo(res.data.data)
                setLoading(false)
            })
            .catch(err => {
                console.log(err)
                setLoading(false)
            })
    }, [])
    return (
        <>
            <section>
                <div className="manage-title">{merchantInfo.merchantName}</div>
                <div className="manage-wrapper">
                    <div>预计收入/元 {merchantInfo.income}</div>
                    <div>有效订单/单 {merchantInfo.orderNum}</div>
                </div>
                <div>
                    <List>
                        <List.Item prefix={<UnorderedListOutline />} onClick={() => { window.location.href = "http://121.43.147.142:3000/#/grounding" }}>
                            菜品上架
                        </List.Item>
                        {/* http://121.43.147.142:3000/#/maintain */}
                        <List.Item prefix={<SetOutline />} onClick={() => { window.location.href = "http://121.43.147.142:3000/#/maintain" }}>
                            菜品维护
                        </List.Item>
                        <List.Item prefix={<PayCircleOutline />} onClick={() => { }}>
                            活动中心
                        </List.Item>
                        <List.Item prefix={<PayCircleOutline />} onClick={() => { }}>
                            优惠卷设置
                        </List.Item>
                    </List>
                </div>
            </section>
        </>
    )
}

export default Manage